<!-- templates/admin/dashboard.html -->
{% extends "base.html" %}

{% block title %}管理后台 - 校园摄影投票系统{% endblock %}

{% block content %}
    <div class="container-fluid">
        <h1 class="mt-4">管理仪表盘</h1>
        
        <div class="row mt-4">
            <div class="col-xl-3 col-md-6 mb-4">
                <div class="card border-left-primary shadow h-100 py-2">
                    <div class="card-body">
                        <div class="row no-gutters align-items-center">
                            <div class="col mr-2">
                                <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
                                    <a href="{{ url_for('admin.manage_photos') }}">用户总数</a></div>
                                <div class="h5 mb-0 font-weight-bold text-gray-800">{{ total_users }}</div>
                            </div>
                            <div class="col-auto">
                                <i class="fas fa-users fa-2x text-gray-300"></i>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="col-xl-3 col-md-6 mb-4">
                <div class="card border-left-success shadow h-100 py-2">
                    <div class="card-body">
                        <div class="row no-gutters align-items-center">
                            <div class="col mr-2">
                                <div class="text-xs font-weight-bold text-success text-uppercase mb-1">
                                    <a href="{{ url_for('admin.manage_photos') }}">作品总数</a></div>
                                <div class="h5 mb-0 font-weight-bold text-gray-800">{{ total_photos }}</div>
                            </div>
                            <div class="col-auto">
                                <i class="fas fa-camera fa-2x text-gray-300"></i>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="col-xl-3 col-md-6 mb-4">
                <div class="card border-left-warning shadow h-100 py-2">
                    <div class="card-body">
                        <div class="row no-gutters align-items-center">
                            <div class="col mr-2">
                                <div class="text-xs font-weight-bold text-warning text-uppercase mb-1">
                                    <a href="{{ url_for('admin.manage_photos') }}">待审作品</a></div>
                                <div class="h5 mb-0 font-weight-bold text-gray-800">{{ pending_photos }}</div>
                            </div>
                            <div class="col-auto">
                                <i class="fas fa-clock fa-2x text-gray-300"></i>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="row mt-4">
            <div class="col-lg-6">
                <div class="card shadow mb-4">
                    <div class="card-header py-3">
                        <h6 class="m-0 font-weight-bold text-primary">最新上传作品</h6>
                    </div>
                    <div class="card-body">
                        <div class="list-group">
                            {% for photo in latest_photos %}
                            <a href="{{ url_for('main.photo_detail', photo_id=photo.id) }}" 
                               class="list-group-item list-group-item-action">
                                <div class="d-flex w-100 justify-content-between">
                                    <h6 class="mb-1">{{ photo.title }}</h6>
                                    <small>{{ photo.created_at.strftime('%m-%d %H:%M') }}</small>
                                </div>
                                <p class="mb-1">{{ photo.description|truncate(50) }}</p>
                                <small>作者: {{ photo.author.username }}</small>
                            </a>
                            {% endfor %}
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="col-lg-6">
                <div class="card shadow mb-4">
                    <div class="card-header py-3">
                        <h6 class="m-0 font-weight-bold text-primary">最新注册用户</h6>
                    </div>
                    <div class="card-body">
                        <div class="list-group">
                            {% for user in latest_users %}
                            <a href="{{ url_for('main.user_profile', username=user.username) }}" 
                               class="list-group-item list-group-item-action">
                                <div class="d-flex w-100 justify-content-between">
                                    <h6 class="mb-1">{{ user.username }}</h6>
                                    <small>{{ user.created_at.strftime('%m-%d %H:%M') }}</small>
                                </div>
                                <p class="mb-1">{{ user.email }}</p>
                            </a>
                            {% endfor %}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}